Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added writing XMP bytes to JPEG #8286

Merged
merged 4 commits into from
Sep 4, 2024
Merged

Added writing XMP bytes to JPEG #8286

merged 4 commits into from
Sep 4, 2024

Conversation

radarhere
Copy link
Member

@radarhere radarhere commented Aug 5, 2024

Resolves #8283, allowing XMP data to be saved to JPEG files, either by

im.save("out.jpg", xmp=b"test")

or

im.info["xmp"] = b"test"
im.save("out.jpg")

@radarhere radarhere added the JPEG label Aug 5, 2024
@cmahnke
Copy link

cmahnke commented Aug 5, 2024

Thanks!
But please keep in mind that there is a size limit of about 64Kb on this field, see Spec, page 14. How about raising an error if it's exceeded?

xmp = info.get("xmp")
if xmp:
size = o16(31 + len(xmp))
overhead_len = 29
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a comment that this is len('http://ns.adobe.com/xap/1.0/'+ b"\0")? Otherwise a reader not famliar with the matter might come to the conclusion that this is just a(nother) magic number.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I've added a comment.

@hugovk hugovk merged commit 95c867d into python-pillow:main Sep 4, 2024
47 of 48 checks passed
@radarhere radarhere deleted the xmp branch September 4, 2024 21:20
radarhere added a commit to radarhere/Pillow that referenced this pull request Sep 10, 2024
radarhere added a commit to radarhere/Pillow that referenced this pull request Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add XMP writing
3 participants